<?php
echo $this->headScript()->prependFile($this->baseUrl().'/templates/admin/js/tinymce/jscripts/tiny_mce/tiny_init_mini.js')
->prependFile($this->baseUrl().'/templates/admin/js/tinymce/jscripts/tiny_mce/tiny_mce.js')
->prependFile($this->baseUrl().'/templates/admin/js/decodeslug.js');
?>

<script type="text/javascript">
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
};

function checkNum(num) {
	if(isNaN(num.value)) {
		alert('Vui lòng nhập số!');
		num.value = '';	
	}
}

function check(f) {
	if(f.name.value == '') return false;
	if(f.alias.value == '') return false;
	if(f.link.value == '') return false;
	if(isNaN(f.sort.value) || f.sort.value.trim() == '') return false;
//	if(f.axam_code.value.trim() == '') return false;
//	if(f.answer.value.trim() == '') return false;
	return true;
}
function submitForm(opt) {
	var f = document.adminForm;
	if(check(f)) {
		if(opt == 0) {
			f.savenew.value = 1;			
		}		
		f.submit();
	} else {
		alert('Vui lòng nhập các dữ liệu có dấu (*)!');
	}
}
</script>

<div id="toolbar-box">
	<div class="t">
		<div class="t">
			<div class="t"></div>
		</div>
	</div>
	<div class="m">
		<div id="toolbar" class="toolbar-list">
			<ul>
				<li id="toolbar-apply" class="button"><a class="toolbar"
					onclick="submitForm(1);" href="#"> <span class="icon-32-apply"> </span>
						Lưu </a></li>

				<li id="toolbar-save-new" class="button"><a class="toolbar" href="#">
						<span class="icon-32-save-new" onclick="submitForm(0);"> </span>
						Lưu &amp; Thêm </a></li>

				<li id="toolbar-cancel" class="button"><a class="toolbar"
					href="<?php echo $this->url(array('module'=>'admin','controller'=>'intro','action'=>'show'));?>">
						<span class="icon-32-cancel"> </span> Thoát </a></li>


			</ul>
			<div class="clr"></div>
		</div>
		<div class="pagetitle icon-48-article">
			<h2>Quản lý Intro</h2>
		</div>
		<div class="clr"></div>
	</div>
	<div class="b">
		<div class="b">
			<div class="b"></div>
		</div>
	</div>
</div>

<!-- content -->

<div id="element-box">
	<div class="t">
		<div class="t">
			<div class="t"></div>
		</div>
	</div>
	<div class="m">

		<form class="form-validate" id="item-form" name="adminForm"
			method="post" enctype="multipart/form-data"
			action="<?php echo $this->url(array('controller'=>'intro', 'module'=>'admin', 'action'=>'save'),'default',true); ?>">
			<div class="width-100 fltlft">
				<fieldset class="adminform">
					<legend>Intro</legend>
					<ul class="adminformlist">

						<li><label title="" class="hasTip" for="name" id="jform_title-lbl">Tên
								hiển thị<span class="star">&nbsp;*</span> </label> <input
							type="text" size="50" class="inputbox" onkeydown=""
							value="<?php if($this->intro) echo $this->intro['name'];?>"
							id="name" name="name"></li>

						<li><label title="" class="hasTip" for="alias" id="alias-title">Alias<span
								class="star">&nbsp;*</span> </label> <input type="text"
							size="50" class="inputbox"
							value="<?php if($this->intro) echo $this->intro['alias'];?>"
							id="alias" name="alias"></li>
						<li><label title="" class="hasTip" for="link" id="link-title">Liên
								kết<span class="star">&nbsp;*</span> </label> <input type="text"
							size="50" class="inputbox"
							value="<?php if($this->intro) echo $this->intro['link'];?>"
							id="link" name="link"></li>
						<li><label title="" class="hasTip" for="icon" id="icon-title">Icon
								(Size 50 x 50)<span class="star">&nbsp;*</span> </label> <input
							type="file" size="35" class="inputbox" id="icon" name="icon"></li>
						<li><label title="" class="hasTip" for="icon" id="icon-title"></label>
						<?php
						if($this->intro && $this->intro['logo'] != null):
						echo '<img src="'.$this->baseUrl().'/upload/icons/'.$this->intro['logo'].'" width="40" />';
						endif;
						?>
						</li>
						<li><label title="" class="hasTip" for="sort" id="icon-title">Thứ
								tự<span class="star">&nbsp;*</span> </label> <input type="text"
							size="35" class="inputbox" onkeydown="checkNum(this);"
							value="<?php if($this->intro) echo $this->intro['sort'];?>"
							id="sort" name="sort"></li>
						<li><label title="" class="hasTip" for="sort" id="icon-title">Active<span
								class="star">&nbsp;*</span> </label> <input type="checkbox"
							id="active" name="active" value="1"
							<?php if($this->intro && $this->intro['active'] == 1) echo 'checked=checked'?>>
						</li>
					</ul>
					<div class="clr"></div>
					<label title="" class="hasTip" for="ask" id="jform_ask-lbl">Nội
						dung</label>
					<div style="float: left; width: 100%">
						<textarea rows="15" style="width: 100%;" id="desc" name="desc">
						<?php if($this->intro) echo $this->intro['description'];?>
						</textarea>
					</div>


					<div class="clr"></div>

				</fieldset>

			</div>
			<div class="clr"></div>
			<input type="hidden" value="0" name="savenew" /> <input type="hidden"
				value="<?php if($this->intro) echo $this->intro['id'];?>" name="id" />
		</form>
	</div>
	<div class="b">
		<div class="b">
			<div class="b"></div>

			<div class="clr"></div>
		</div>

	</div>
</div>
